<template>
  <div class="transaction-service-list bg-c-fff right-height mb70">
    <p class="bread">
      <a href="javascript:void(0);" class="font-s-16">首席监控师-交易监控订单纠错管理</a>
    </p>
    <div class="content">
      <table width="100%" class="auto">
        <tr>
          <th>提交时间</th>
          <th>订单编号</th>
          <th>监控师</th>
          <th>申请人姓名</th>
          <th>申请人职务</th>
          <th>订单详情</th>
          <th>纠错申请</th>
          <th>允许修改</th>
        </tr>
        <tr v-for="item in list">
          <td>{{item.createTime}}</td>
          <td>{{item.orderId}}</td>
          <td>{{item.monitorName}}</td>
          <td>{{item.tradeSysName}}</td>
          <td>{{item.tradeType | tradeTypeFilter}}</td>
          <td>
            <button class="blue-button xl-btn-css" @click="onDetailsClick(item.orderId)">查看详情</button>
          </td>
          <td>
            <button class="blue-button xl-btn-css" @click="onConClick(item)">查看内容</button>
          </td>
          <td>
            <button class="blue-button small-btn-css" @click="openModify(item)">{{item.errorStatue | ModifyFilter}}</button>
          </td>
        </tr>
      </table>
      <div class="fix foot-box ">
        <div class="no-data-tip" v-show="list.length===0">暂无相关数据</div>
        <pagination :index="pageIndex " :total="pageTotal " v-show="this.list!=0 " @pagechange="onPageChange "></pagination>
      </div>
    </div>
    <vodal :show="remarkShow " animation="zoom " :width="350 " :height="210 " @hide="remarkShow=false ">
      <div class="vodal-main ">
        <h4>纠错申请</h4>
        <div class="con ">
          <p>备注信息：
            <textarea class="vt " v-model="errorCon ">
            </textarea>
          </p>
        </div>
      </div>
    </vodal>
  </div>
</template>
<script type="text/javascript ">
import Pagination from '../components/Pagination'
export default {
  components: {
    Pagination
  },
  data() {
    return {
      pageIndex: 1,
      pageTotal: 0,
      remarkShow: false,
      list: [],
      errorCon: ''
    }
  },
  mounted() {
    this.onPageChange(1)
  },
  methods: {
    onPageChange(n) {
      this.$http.post('/tradeError/query/trade/error/bychelf', {
        params: {
          page: n,
          rows: 10
        }
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.pageIndex = n
          this.pageTotal = Math.ceil(data.data.total / 10)
          this.list = data.data.rows
        } else {
          console.log(data.data.msg)
          this.$toasted.show(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    onDetailsClick(id) {
      this.$router.push('/cm-transaction-aptitude?id=' + id)
    },
    onConClick(item) {
      this.errorCon = item.errorContent
      this.remarkShow = true
    },
    openModify(item) {
      if (item.errorStatue === 0) {
        this.$http.post('/transactionMonitorSer/modify', {
          id: item.id
        }).then(data => {
          if (data.data.httpCode === 200) {
            this.$toasted.show('开启成功！')
            this.list.forEach((i) => {
              if (i.id === item.id) {
                i.errorStatue = 1
              }
            })
          } else {
            console.log(data.data.msg)
            this.$toasted.show(data.data.msg)
          }
        }).catch(err => {
          console.log(err)
        })
      }
    }
  },
  filters: {
    tradeTypeFilter(v) {
      if (v === 1) {
        return '交易监控师'
      } else if (v === 2) {
        return '交易监控员'
      }
    },
    ModifyFilter(v) {
      if (v === 1) {
        return '已开启'
      } else if (v === 0) {
        return '开启'
      }
    }
  }
}

</script>
<style type="text/css " scoped>
.bread {
  padding-left: 20px;
  border-bottom: 1px solid #ddd;
}

.bread a {
  line-height: 45px;
}

.content {
  padding: 0 30px 30px;
}

.bread button {
  right: 10px;
  top: 8px;
}

table {
  margin-top: 30px;
}

.foot-box {
  padding: 35px 0px 0px 0px;
}

textarea {
  width: 236px;
  height: 125px;
  padding: 5px 8px;
}

</style>
